home *** CD-ROM | disk | FTP | other *** search
- window.addEventListener("load",function(event){hotmailsig.pageload(event)},false);
- window.addEventListener("unload",function(event){hotmailsig.uninitSig(event)},false);
-
- var hotmailsig =
- {
- current: null,
- COMPOSE: "EditMessageLight",
- loading: false,
- doc: null,
- pageload: function (event)
- {
- // WISELOG("[hotmail.js::pageload] >>>>>");
- try
- {
- if (!this.loading)
- {
- var doc = event.originalTarget;
- if (doc instanceof Components.interfaces.nsIDOMDocument)
- {
- // WISELOG("[hotmail.js::pageload] defaultView frame?: "+doc.defaultView.frameElement);
- if (doc.defaultView.frameElement)
- {
- var fclass = doc.defaultView.frameElement.getAttribute("class");
- // WISELOG("[hotmail.js::pageload] frame class: "+fclass);
- // Frame within a tab was loaded. doc should be the root document of
- // the frameset.
- // Find the root document:
- while (doc.defaultView.frameElement)
- {
- doc = doc.defaultView.frameElement.ownerDocument;
- }
- }
-
- this.doc = doc;
- }
-
- if (this.doc)
- {
- // WISELOG("[hotmail.js::pageload] this.doc");
- this.loading = true;
- wisestampsig.refreshCallback = hotmailsig.refreshSignature;
- setTimeout(function ()
- {
- hotmailsig.init();
- },
- 1000);
- }
- }
- } catch(e)
- {
- // WISELOG(e);
- }
- },
- uninitSig: function ()
- {
- var viewDiv = document.getElementById("ws_view");
- if (viewDiv) viewDiv.removeEventListener("DOMNodeInserted", hotmailsig.composeInserted, false);
- var compose = document.getElementById("composeMessage");
- if (compose)
- {
- try
- {
- this._composeListener = false;
- compose.removeEventListener("DOMAttrModified", hotmailsig.composeModified, false);
- } catch(e)
- {
-
- }
- }
- this.uninitView();
- },
- uninitView: function ()
- {
- if (this.current && this["uninit" + this.current])
- {
- this["uninit" + this.current]();
- }
- },
- init: function ()
- {
- // WISELOG("[hotmail.js::init] SetupCompose");
- var reg = /.+mail\.live\..+\/mail\/(.+)\.aspx.+/;
- // WISELOG("[hotmail.js::init] location = " + location.toString());
- var result = location.toString().match(reg);
- // WISELOG("[hotmail.js::init] result = "+result);
- if (result && result[1])
- {
- var mode = result[1];
- // WISELOG("[hotmail.js::init] MODE: "+mode);
- switch (mode)
- {
- case this.COMPOSE:
- this.setupCompose();
- break;
- default:
- break;
- }
- }
- },
- get mode()
- {
- var search = location.search;
- var reg = /Action=([^&]+)/;
- var m = search.match(reg);
- if (m && m[1])
- {
- return m[1];
- } else
- {
- return null;
- }
- },
- iframeTries: 0,
- setupCompose: function (aSkipCheck)
- {
- // WISELOG("[hotmail.js::setupCompose] >>>>>");
- if (!aSkipCheck && document.getElementById("wisestamp_toolbarbutton"))
- {
- // WISELOG("[hotmail.js::setupCompose] Already loaded");
- return;
- }
- //var toolbars = evaluateXPath(document,
- // "//div[@id='mainToolbar']//ul[@class='Toolbar']");
- var toolbars = evaluateXPath(document,
- //"//div[@class='MSN_EDITCONTAINER']//div[@class='MSN_TOOLBAR']");
- "//div[@class='ButtonList Enabled']");
- // WISELOG("[hotmail.js::setupCompose] toolbars = "+toolbars);
- if (toolbars.length > 0)
- {
- var toolbar = toolbars[0];
- this.addWisestampIcon(toolbar);
-
- var iframes = evaluateXPath(document, "//iframe[@class='RichText']");
- if (this.mode == "ResumeDraft") this.iframe = iframes[0];
- else
- {
- for (var i = 0; iframes && i < iframes.length; i++)
- this.insertSignature(iframes[i], false);
- }
- }
- },
- addWisestampIcon: function (toolbar)
- {
- // WISELOG("[hotmail.js::addWisestampIcon] >>>>>");
- if (!wisestampsig.showButton) return;
- var end = toolbar.childNodes[toolbar.childNodes.length - 1];
- var li = hotmailsig.doc.createElement("span");
- li.setAttribute("id", "wisestamp_toolbarbutton");
- li.setAttribute("class", "MSN_TOOLBAR_GROUP");
- li.setAttribute("style", "display: inline; white-space: nowrap;");
- var span = hotmailsig.doc.createElement("span");
- span.setAttribute("tabindex", "0");
- var width = "24";
- if (wisestampsig.isFoxytunesInstalled) width = "55"
- span.setAttribute("style", "float: right; position: relative; display: inline; width: " + width + "px; height: 30px; vertical-align: middle;")
- var img = hotmailsig.doc.createElement("img");
- img.setAttribute("src", wisestampsig.icon);
- img.setAttribute("alt", "Wisestamp");
- img.setAttribute("style", "width: 16px; height: 16px; vertical-align: bottom; position: absolute; margin-left: 5px; margin-top: 14px;");
- span.appendChild(img);
- li.appendChild(span);
- var spacer = document.createElement("table");
- spacer.setAttribute("style", "width: 35px; height: 20px; position: absolute;");
- //li.appendChild(spacer);
- toolbar.insertBefore(li, end);
- //toolbar.appendChild(li);
- wisestampsig.initOptionsIcon(li);
- },
- uninitCompose: function ()
- {
-
- },
- iframeTries: 1,
- refreshSignature: function ()
- {
- wisestampsig.insertSignature(hotmailsig.iframe, false);
- },
- insertSignature: function (iframe)
- {
- // WISELOG("[hotmail.js::insertSignature] >>>>>");
- this.iframe = iframe;
- this.iframeLoad(false);
- },
- iframeLoad: function (event)
- {
- // WISELOG("[hotmail.js::iframeLoad] >>>>>");
- wisestampsig.insertSignature(hotmailsig.iframe, true);
- }
- };